package com.ninetaildemonfox.zdl.socialproject.mvp.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
import com.ninetaildemonfox.zdl.socialproject.R;
import com.ninetaildemonfox.zdl.socialproject.mvp.ui.adapter.viewholder.HomeAdViewHolder;

import java.util.Map;

/**
 * 创建人： Nine tails fox
 * 创建时间： 2019/7/16
 * 功能描述：
 * 联系方式：1037438704@qq.com
 *
 * @author NineTailDemonFox
 */

public class DHomeAdapter extends RecyclerArrayAdapter<Map<String, String>> {
    private final LayoutInflater mLayoutInflater;

    private int jump = 0;

    public DHomeAdapter(Context context) {
        super(context);
        mLayoutInflater = LayoutInflater.from(context);
    }

    public void setJump(int jump) {
        this.jump = jump;
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(final ViewGroup parent, int viewType) {
        HomeAdViewHolder homeAdViewHolder = new HomeAdViewHolder(mLayoutInflater.inflate(R.layout.list_d_home, parent, false));
        homeAdViewHolder.setJump(jump);
        homeAdViewHolder.setmOnClick(new HomeAdViewHolder.ItemOnClick() {
            @Override
            public void onClick(int position, Map<String, String> data, int type) {
                if (mOnClick != null) {
                    mOnClick.onClick(position, data, type);
                }
            }
        });
        return homeAdViewHolder;
    }

    private AdpItemOnClick mOnClick = null;


    //点击事件的转嫁接口
    public interface AdpItemOnClick {
        void onClick(int position, Map<String, String> data, int type);
    }

    public void setmOnClick(AdpItemOnClick mOnClick) {
        this.mOnClick = mOnClick;
    }

}
